﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using KaoQin.BLL;
using KaoQin.Model;

namespace KaoQin.WPFApp.sys.User
{
    /// <summary>
    /// ModifyUserBaseInfo.xaml 的交互逻辑
    /// </summary>
    public partial class ModifyUserBaseInfo : Window
    {
        public ModifyUserBaseInfo()
        {
            InitializeComponent();
        }

        private SysUsersInfo UserInfo = null;

        public ModifyUserBaseInfo(SysUsersInfo user)
        {
            InitializeComponent();

            this.UserInfo = user;
            txtReadName.Text = this.UserInfo.RealName;
            this.gridInfo.DataContext = this.UserInfo;
        }

        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                SysUsersInfo model = (SysUsersInfo)gridInfo.DataContext;

                if (string.IsNullOrEmpty(model.RealName))
                {
                    MessageBox.Show("真实姓名不能为空");
                    return;
                }
                new SysUsers().Update(model);
                MessageBox.Show("修改成功");
                
            }
            catch (Exception ex)
            {
                MessageBox.Show("基本信息修改成功:" + ex.Message);
            }
        }

        private void btnClose_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }
    }
}
